<?php

//error_reporting(E_ERROR | E_WARNING | E_PARSE);
mysql_connect(localhost, root, root);
@mysql_select_db(dinocap2) or die("Unable to select database");
set_time_limit(0);
ini_set("memory_limit", "200M");
//$dateTime = date("Y-m-d",strtotime("-1 day"));
//$handle = fopen("http://192.168.0.185/log/test/$dateTime.'b'", "r");
$handle = fopen("http://192.168.0.185/log/dinocap2/404ab", "r");
while (!feof($handle)) {
    $buffer = fgets($handle, 10960);
    // $array[] = $buffer;
    $arr = json_decode($buffer, true);
    $id100 = $arr["data"];
    $arr2 = json_decode($id100, true);

    $id101 = $arr2["missionType1State"];    //missionType1State arry3
    $arr3 = json_decode($id101, true);
    $id102 = $arr2["missionType2State"];    //missionType2State arry4
    $arr4 = json_decode($id102, true);
    $id103 = $arr2["missionType3State"];    //missionType3State  arry5
    $arr5 = json_decode($id103, true);
    $id104 = $arr2["missionType4State"];     //missionType4State  arry6
    $arr6 = json_decode($id104, true);
    $id105 = $arr2["missionType5State"];     //missionType5State  arry7
    $arr7 = json_decode($id105, true);
    $id106 = $arr2["missionType6State"];     //missionType6State  arry8
    $arr8 = json_decode($id106, true);
    $id107 = $arr2["missionType7State"];     //missionType7State  arry9
    $arr9 = json_decode($id107, true);
    $id108 = $arr2["missionType8State"];     //missionType8State  arry10
    $arr10 = json_decode($id108, true);
    $id109 = $arr2["player1Info"];    //player1Info arry11
    $arr11 = json_decode($id109, true);

    $id110 = $arr11["player1Weapon1Info"];    //player1Info-player1Weapon1Info arry12
    $arr12 = json_decode($id110, true);

    $id111 = $arr11["player1Weapon2Info"];    //player1Weapon2Info  arry13
    $arr13 = json_decode($id111, true);
    $id112 = $arr11["player1Weapon3Info"];    //player1Weapon3Info arry14
    $arr14 = json_decode($id112, true);

    $id113 = $arr11["player1Weapon4Info"];    //player1Weapon4Info arry15
    $arr15 = json_decode($id113, true);
    $id114 = $arr11["player1Weapon5Info"];    // player1Weapon5Info arry16
    $arr16 = json_decode($id114, true);
    $id115 = $arr11["player1Weapon6Info"];    //  player1Weapon6Info arry17
    $arr17 = json_decode($id115, true);
    $id116 = $arr2["player2Info"];    //player2Info arry18
    $arr18 = json_decode($id116, true);
    $id117 = $arr18["player2Weapon1Info"];    //player2Weapon1Info arry 19
    $arr19 = json_decode($id117, true);
    $id118 = $arr18["player2Weapon2Info"];    //player2Weapon2Info  arry20
    $arr20 = json_decode($id118, true);
    $id119 = $arr18["player2Weapon3Info"];    //player2Weapon3Info  arry21
    $arr21 = json_decode($id119, true);
    $id120 = $arr18["player2Weapon4Info"];     //player2Weapon4Info arry 22
    $arr22 = json_decode($id120, true);
    $id121 = $arr18["player2Weapon5Info"];     //player2Weapon5Info arry 23
    $arr23 = json_decode($id121, true);
    $id122 = $arr18["player2Weapon6Info"];     //player2Weapon6Info arry 24
    $arr24 = json_decode($id122, true);

    $id123 = $arr2["player3Info"];    //player3Info arry25
    $arr25 = json_decode($id123, true);
    $id124 = $arr25["player3Weapon1Info"];    //player3Weapon1Info arry 26
    $arr26 = json_decode($id124, true);
    $id125 = $arr25["player3Weapon2Info"];    //player3Weapon2Info  arry27
    $arr27 = json_decode($id125, true);
    $id126 = $arr25["player3Weapon3Info"];    //player3Weapon3Info  arry28
    $arr28 = json_decode($id126, true);
    $id127 = $arr25["player3Weapon4Info"];     //player3Weapon4Info arry 29
    $arr29 = json_decode($id127, true);
    $id128 = $arr25["player3Weapon5Info"];     //player3Weapon5Info arry 30
    $arr30 = json_decode($id128, true);
    $id129 = $arr25["player3Weapon6Info"];     //player3Weapon6Info arry 31
    $arr31 = json_decode($id129, true);

    $id130 = $arr2["player4Info"];    //player4Info arry32
    $arr32 = json_decode($id130, true);
    $id131 = $arr32["player4Weapon1Info"];    //player4Weapon1Info arry 33
    $arr33 = json_decode($id131, true);
    $id132 = $arr32["player4Weapon2Info"];    //player4Weapon2Info  arry34
    $arr34 = json_decode($id132, true);
    $id133 = $arr32["player4Weapon3Info"];    //player4Weapon3Info  arry35
    $arr35 = json_decode($id133, true);
    $id134 = $arr32["player4Weapon4Info"];     //player4Weapon4Info arry 36
    $arr36 = json_decode($id134, true);
    $id135 = $arr32["player4Weapon5Info"];     //player4Weapon5Info arry 37
    $arr37 = json_decode($id135, true);
    $id136 = $arr32["player4Weapon6Info"];     //player4Weapon6Info arry 38
    $arr38 = json_decode($id136, true);

    $id137 = $arr2["player5Info"];    //player5Info arry39
    $arr39 = json_decode($id137, true);
    $id138 = $arr39["player5Weapon1Info"];    //player5Weapon1Info arry 40
    $arr40 = json_decode($id138, true);
    $id139 = $arr39["player5Weapon2Info"];    //player5Weapon2Info  arry41
    $arr41 = json_decode($id139, true);
    $id140 = $arr39["player5Weapon3Info"];    //player5Weapon3Info  arry42
    $arr42 = json_decode($id140, true);
    $id141 = $arr39["player5Weapon4Info"];     //player5Weapon4Info arry 43
    $arr43 = json_decode($id141, true);
    $id142 = $arr39["player5Weapon5Info"];     //player5Weapon5Info arry 44
    $arr44 = json_decode($id142, true);
    $id143 = $arr39["player5Weapon6Info"];     //player5Weapon6Info arry 45
    $arr45 = json_decode($id143, true);

    $id = $arr2["dayGetMoney"];
    $id2 = $arr2["dayIap1BuyTimes"];
    $id3 = $arr2["dayIap2BuyTimes"];
    $id4 = $arr2["dayIap3BuyTimes"];
    $id5 = $arr2["dayIap4BuyTimes"];
    $id6 = $arr2["dayIap5BuyTimes"];
    $id7 = $arr2["dayIap6BuyTimes"];
    $id8 = $arr2["dayIapMoney"];
    $id9 = $arr2["dayPlayTime"];
    $id10 = $arr2["dayTotalTime"];

    $id11 = $arr2["dayUI1TapCount"];  //2
    $id12 = $arr2["dayUI2TapCount"];
    $id13 = $arr2["dayUI3TapCount"];
    $id14 = $arr2["dayUI4TapCount"];
    $id15 = $arr2["dayUI5TapCount"]; //3
    $id16 = $arr2["dayUI6TapCount"];
    $id17 = $arr2["dayUI7TapCount"];
    $id18 = $arr2["dayUI8TapCount"];
    $id19 = $arr2["dayUI9TapCount"]; //4
    $id20 = $arr2["dayUsedMoney"];
    $id21 = $arr2["firstlogindata"];
    $id22 = $arr2["fromNotificationCount"];
    $id23 = $arr2["isjailbreak"]; //5
    $id24 = $arr2["lastMission"];
    $id25 = $arr2["lastMissionState"];
    $id26 = $arr2["lastMissionType"];
    $id27 = $arr2["lastTapUI"];

    $id28 = $arr3["mission1End"]; //missionType1State $arry3
    $id29 = $arr3["mission1Exit"];
    $id30 = $arr3["mission1Retry"];
    $id31 = $arr3["mission1Select"];
    $id32 = $arr4["mission2End"];         //missionType2State arry4
    $id33 = $arr4["mission2Exit"];
    $id34 = $arr4["mission2Retry"];
    $id35 = $arr4["mission2Select"];

    $id36 = $arr5["mission3End"];          //missionType3State arry5
    $id37 = $arr5["mission3Exit"];
    $id38 = $arr5["mission3Retry"];
    $id39 = $arr5["mission3Select"];

    $id40 = $arr6["mission4End"];  //missionType4State  arry6
    $id41 = $arr6["mission4Exit"];
    $id42 = $arr6["mission4Retry"];
    $id43 = $arr6["mission4Select"];

    $id44 = $arr7["mission5End"];      //missionType5State  arry7
    $id45 = $arr7["mission5Exit"];

    $id46 = $arr7["mission5Retry"];
    $id47 = $arr7["mission5Select"];

    $id48 = $arr8["mission6End"];  //missionType6State  arry8
    $id49 = $arr8["mission6Exit"];
    $id50 = $arr8["mission6Retry"];
    $id51 = $arr8["mission6Select"];

    $id52 = $arr9["mission7End"];   //missionType7State  arry9
    $id53 = $arr9["mission7Exit"];  //player2Data
    $id54 = $arr9["mission7Retry"];
    $id55 = $arr9["mission7Select"];

    $id56 = $arr10["mission8End"]; //missionType8State  arry10
    $id57 = $arr10["mission8Exit"];
    $id58 = $arr10["mission8Retry"];
    $id59 = $arr10["mission8Select"];

    $id60 = $arr2["nowMoney"];

    $id61 = $arr11["player1DayExp"];  //player1Info arry11

    $id62 = $arr11["player1Level"];

    $id63 = $arr11["player1TotalExp"];
    $id64 = $arr12["player1Weapon1Level"];    //player1Info-player1Weapon1Info arry12
    $id65 = $arr12["weapon1IsUpdate"];

    $id66 = $arr13["player1Weapon2Level"];  //player1Weapon2Info arry13
    $id67 = $arr13["weapon2IsUpdate"];

    $id68 = $arr14["player1Weapon3Level"]; //player1Weapon3Info arry14
    $id69 = $arr14["weapon3IsUpdate"];

    $id70 = $arr15["player1Weapon4Level"];               //player1Weapon4Info arry15
    $id71 = $arr15["weapon4IsUpdate"];

    $id72 = $arr16["player1Weapon5Level"]; //player1Weapon5Info  arry16
    $id73 = $arr16["weapon5IsUpdate"];

    $id74 = $arr17["player1Weapon6Level"];    //player1Weapon6Info  arry17
    $id75 = $arr17["weapon6IsUpdate"];

    $id76 = $arr11["player1WeaponBulletCount"];

    $id77 = $arr11["player1WeaponBulletMoney"];
    $id78 = $arr11["player1WeaponUpdateCount"];
    $id79 = $arr11["player1WeaponUpdateMoney"];

    $id80 = $arr18["player2DayExp"];     // player2Info arry18

    $id81 = $arr18["player2Level"];
    $id82 = $arr18["player2TotalExp"];
    $id83 = $arr19["player2Weapon1Level"];  //player2Weapon1Info arry19
    $id84 = $arr19["weapon1IsUpdate"];

    $id85 = $arr20["player2Weapon2Level"]; //player2Weapon2Info arry20
    $id86 = $arr20["weapon2IsUpdate"];

    $id87 = $arr21["player2Weapon3Level"];  //player2Weapon3Info  arry21
    $id88 = $arr21["weapon3IsUpdate"];


    $id89 = $arr22["player2Weapon4Level"];        //player2Weapon4Info arry 22
    $id90 = $arr22["weapon4IsUpdate"];

    $id91 = $arr23["player2Weapon5Level"];                 //player2Weapon5Info  arry23
    $id92 = $arr23["weapon5IsUpdate"];

    $id93 = $arr24["player2Weapon6Level"];                   //player2Weapon6Info  arry24
    $id94 = $arr24["weapon6IsUpdate"];

    $id95 = $arr18["player2WeaponBulletCount"];

    $id96 = $arr18["player2WeaponBulletMoney"];
    $id97 = $arr18["player2WeaponUpdateCount"];

    $id98 = $arr18["player2WeaponUpdateMoney"];


    $id99 = $arr25["player3DayExp"];     // player3Info arry25

    $id100a = $arr25["player3Level"];
    $id101a = $arr25["player3TotalExp"];
    $id102a = $arr26["player3Weapon1Level"];  //player3Weapon1Info arry26
    $id103a = $arr26["weapon1IsUpdate"];
    $id104a = $arr27["player3Weapon2Level"]; //player3Weapon2Info arry27
    $id105a = $arr27["weapon2IsUpdate"];

    $id106a = $arr28["player3Weapon3Level"];  //player3Weapon3Info  arry28
    $id107a = $arr28["weapon3IsUpdate"];

    $id108a = $arr29["player3Weapon4Level"];        //player3Weapon4Info arry 29
    $id109a = $arr29["weapon4IsUpdate"];

    $id110a = $arr30["player3Weapon5Level"];                 //player3Weapon5Info  arry30
    $id111a = $arr30["weapon5IsUpdate"];

    $id112a = $arr31["player3Weapon6Level"];                   //player3Weapon6Info  arry31
    $id113a = $arr31["weapon6IsUpdate"];

    $id114a = $arr25["player3WeaponBulletCount"];

    $id115a = $arr25["player3WeaponBulletMoney"];
    $id116a = $arr25["player3WeaponUpdateCount"];

    $id117a = $arr25["player3WeaponUpdateMoney"];



    $id118a = $arr32["player4DayExp"];     //player4Info arry32

    $id119a = $arr32["player4Level"];
    $id120a = $arr32["player4TotalExp"];
    $id121a = $arr33["player4Weapon1Level"];  //player4Weapon1Info arry33
    $id122a = $arr33["weapon1IsUpdate"];

    $id123a = $arr34["player4Weapon2Level"]; //player4Weapon2Info arry34
    $id124a = $arr34["weapon2IsUpdate"];

    $id125a = $arr35["player4Weapon3Level"];  //player4Weapon3Info  arry35
    $id126a = $arr35["weapon3IsUpdate"];

    $id127a = $arr36["player4Weapon4Level"];        //player4Weapon4Info arry 36
    $id128a = $arr36["weapon4IsUpdate"];

    $id129a = $arr37["player4Weapon5Level"];                 //player4Weapon5Info  arry37
    $id130a = $arr37["weapon5IsUpdate"];

    $id131a = $arr38["player4Weapon6Level"];                   //player4Weapon6Info  arry38
    $id132a = $arr38["weapon6IsUpdate"];

    $id133a = $arr32["player4WeaponBulletCount"];

    $id134a = $arr32["player4WeaponBulletMoney"];
    $id135a = $arr32["player4WeaponUpdateCount"];

    $id136a = $arr32["player4WeaponUpdateMoney"];



    $id137a = $arr39["player5DayExp"];     //player5Info arry39

    $id138a = $arr39["player5Level"];
    $id139a = $arr39["player5TotalExp"];
    $id140a = $arr40["player5Weapon1Level"];  //player5Weapon1Info arry40
    $id141a = $arr40["weapon1IsUpdate"];

    $id142a = $arr41["player5Weapon2Level"]; //player5Weapon2Info arry41
    $id143a = $arr41["weapon2IsUpdate"];

    $id144a = $arr42["player5Weapon3Level"];  //player5Weapon3Info  arry42
    $id145a = $arr42["weapon3IsUpdate"];

    $id146a = $arr43["player5Weapon4Level"];        //player5Weapon4Info arry 43
    $id147a = $arr43["weapon4IsUpdate"];

    $id148a = $arr44["player5Weapon5Level"];                 //player5Weapon5Info  arry44
    $id149a = $arr44["weapon5IsUpdate"];

    $id150a = $arr45["player5Weapon6Level"];                   //player5Weapon6Info  arry45
    $id151a = $arr45["weapon6IsUpdate"];

    $id152a = $arr39["player5WeaponBulletCount"];

    $id153a = $arr39["player5WeaponBulletMoney"];
    $id154a = $arr39["player5WeaponUpdateCount"];

    $id155a = $arr39["player5WeaponUpdateMoney"];

    $id156a = $arr2["totalMoney"];

    $id157a = $arr2["totalTime"];

    $id158a = $arr["deviceid"];
    $id159a = $arr["gamename"];
    $id160a = $arr["whatday"];
    $id161a = $arr["createdate"];


    $s = 0;
    foreach ((array) $arr as $item => $value) {   //Warning: Invalid argument supplied for foreach
        $s = count($value); //
    }
    for ($i = 0; $i < $s; $i++) {
        $dayGetMoney = $id;
        $dayIap1BuyTimes = $id2;
        $dayIap2BuyTimes = $id3;
        $dayIap3BuyTimes = $id4;
        $dayIap4BuyTimes = $id5;
        $dayIap5BuyTimes = $id6;
        $dayIap6BuyTimes = $id7;
        $dayIapMoney = $id8;
        $dayPlayTime = $id9;
        $dayTotalTime = $id10;
        $dayUI1TapCount = $id11;
        $dayUI2TapCount = $id12;
        $dayUI3TapCount = $id13;
        $dayUI4TapCount = $id14;
        $dayUI5TapCount = $id15;
        $dayUI6TapCount = $id16;
        $dayUI7TapCount = $id17;
        $dayUI8TapCount = $id18;
        $dayUI9TapCount = $id19;
        $dayUsedMoney = $id20;
        $firstlogindata = $id21;
        $fromNotificationCount = $id22;
        $isjailbreak = $id23;
        $lastMission = $id24;
        $lastMissionState = $id25;
        $lastMissionType = $id26;
        $lastTapUI = $id27;
        $mission1End = $id28;
        $mission1Exit = $id29;
        $mission1Retry = $id30;
        $mission1Select = $id31;
        $mission2End = $id32;
        $mission2Exit = $id33;
        $mission2Retry = $id34;
        $mission2Select = $id35;
        $mission3End = $id36;
        $mission3Exit = $id37;
        $mission3Retry = $id38;
        $mission3Select = $id39;
        $mission4End = $id40;
        $mission4Exit = $id41;
        $mission4Retry = $id42;
        $mission4Select = $id43;
        $mission5End = $id44;
        $mission5Exit = $id45;
        $mission5Retry = $id46;
        $mission5Select = $id47;
        $mission6End = $id48;
        $mission6Exit = $id49;
        $mission6Retry = $id50;
        $mission6Select = $id51;
        $mission7End = $id52;
        $mission7Exit = $id53;
        $mission7Retry = $id54;
        $mission7Select = $id55;
        $mission8End = $id56;
        $mission8Exit = $id57;
        $mission8Retry = $id58;
        $mission8Select = $id59;
        $nowMoney = $id60;
        $player1DayExp = $id61;
        $player1Level = $id62;
        $player1TotalExp = $id63;
        $player1Weapon1Level = $id64;
        $weapon1IsUpdate = $id65;
        $player1Weapon2Level = $id66;
        $weapon2IsUpdate = $id67;
        $player1Weapon3Level = $id68;
        $weapon3IsUpdate = $id69;
        $player1Weapon4Level = $id70;
        $weapon4IsUpdate = $id71;
        $player1Weapon5Level = $id72;
        $weapon5IsUpdate = $id73;
        $player1Weapon6Level = $id74;
        $weapon6IsUpdate = $id75;
        $player1WeaponBulletCount = $id76;
        $player1WeaponBulletMoney = $id77;
        $player1WeaponUpdateCount = $id78;
        $player1WeaponUpdateMoney = $id79;
        $player2DayExp = $id80;
        $player2Level = $id81;
        $player2TotalExp = $id82;
        $player2Weapon1Level = $id83;
        $weapon1IsUpdate_2 = $id84;
        $player2Weapon2Level = $id85;
        $weapon2IsUpdate_2 = $id86;
        $player2Weapon3Level = $id87;
        $weapon3IsUpdate_2 = $id88;

        $player2Weapon4Level = $id89;
        $weapon4IsUpdate_2 = $id90;
        $player2Weapon5Level = $id91;
        $weapon5IsUpdate_2 = $id92;
        $player2Weapon6Level = $id93;
        $weapon6IsUpdate_2 = $id94;
        $player2WeaponBulletCount = $id95;
        $player2WeaponBulletMoney = $id96;
        $player2WeaponUpdateCount = $id97;
        $player2WeaponUpdateMoney = $id98;
        $player3DayExp = $id99;
        $player3Level = $id100a;
        $player3TotalExp = $id101a;
        $player3Weapon1Level = $id102a;
        $weapon1IsUpdate_3 = $id103a;
        $player3Weapon2Level = $id104a;
        $weapon2IsUpdate_3 = $id105a;
        $player3Weapon3Level = $id106a;
        $weapon3IsUpdate_3 = $id107a;
        $player3Weapon4Level = $id108a;
        $weapon4IsUpdate_3 = $id109a;
        $player3Weapon5Level = $id110a;
        $weapon5IsUpdate_3 = $id111a;
        $player3Weapon6Level = $id112a;
        $weapon6IsUpdate_3 = $id113a;
        $player3WeaponBulletCount = $id114a;
        $player3WeaponBulletMoney = $id115a;
        $player3WeaponUpdateCount = $id116a;
        $player3WeaponUpdateMoney = $id117a;
        $player4DayExp = $id118a;
        $player4Level = $id119a;
        $player4TotalExp = $id120a;
        $player4Weapon1Level = $id121a;
        $weapon1IsUpdate_4 = $id122a;
        $player4Weapon2Level = $id123a;
        $weapon2IsUpdate_4 = $id124a;
        $player4Weapon3Level = $id125a;
        $weapon3IsUpdate_4 = $id126a;
        $player4Weapon4Level = $id127a;
        $weapon4IsUpdate_4 = $id128a;
        $player4Weapon5Level = $id129a;
        $weapon5IsUpdate_4 = $id130a;
        $player4Weapon6Level = $id131a;
        $weapon6IsUpdate_4 = $id132a;

        $player4WeaponBulletCount = $id133a;
        $player4WeaponBulletMoney = $id134a;
        $player4WeaponUpdateCount = $id135a;
        $player4WeaponUpdateMoney = $id136a;
        $player5DayExp = $id137a;
        $player5Level = $id138a;
        $player5TotalExp = $id139a;
        $player5Weapon1Level = $id140a;
        $weapon1IsUpdate_5 = $id141a;
        $player5Weapon2Level = $id142a;
        $weapon2IsUpdate_5 = $id143a;
        $player5Weapon3Level = $id144a;
        $weapon3IsUpdate_5 = $id145a;
        $player5Weapon4Level = $id146a;
        $weapon4IsUpdate_5 = $id147a;
        $player5Weapon5Level = $id148a;
        $weapon5IsUpdate_5 = $id149a;
        $player5Weapon6Level = $id150a;
        $weapon6IsUpdate_5 = $id151a;
        $player5WeaponBulletCount = $id152a;
        $player5WeaponBulletMoney = $id153a;
        $player5WeaponUpdateCount = $id154a;

        $player5WeaponUpdateMoney = $id155a;
        $totalMoney = $id156a;
        $totalTime = $id157a;
        $deviceid = $id158a;
        $gamename = $id159a;
        $whatday = $id160a;
        $createdate = $id161a;



        mysql_query("INSERT INTO dinocap2hd_query (dayGetMoney, dayIap1BuyTimes,dayIap2BuyTimes,dayIap3BuyTimes,dayIap4BuyTimes,dayIap5BuyTimes,dayIap6BuyTimes,dayIapMoney,dayPlayTime,dayTotalTime,dayUI1TapCount,dayUI2TapCount,dayUI3TapCount,dayUI4TapCount,
                                          dayUI5TapCount,dayUI6TapCount,dayUI7TapCount,dayUI8TapCount,dayUI9TapCount,dayUsedMoney,firstlogindata,firstlogin,fromNotificationCount,isjailbreak,lastMission,lastMissionState,lastMissionType,
                                          lastTapUI,mission1End,mission1Exit,mission1Retry,mission1Select,mission2End,mission2Exit,mission2Retry,mission2Select,mission3End,mission3Exit,mission3Retry,
                                          mission3Select,mission4End,mission4Exit,mission4Retry,mission4Select,mission5End,mission5Exit,mission5Retry,mission5Select,mission6End,mission6Exit,mission6Retry,
                                          mission6Select,mission7End,mission7Exit,mission7Retry,mission7Select,mission8End,mission8Exit,mission8Retry,mission8Select,nowMoney,player1DayExp,player1Level,player1TotalExp,
                                          player1Weapon1Level,weapon1IsUpdate,player1Weapon2Level,weapon2IsUpdate,player1Weapon3Level,weapon3IsUpdate,player1Weapon4Level,weapon4IsUpdate,player1Weapon5Level,weapon5IsUpdate,
                                          player1Weapon6Level,weapon6IsUpdate,player1WeaponBulletCount,player1WeaponBulletMoney,player1WeaponUpdateCount,player1WeaponUpdateMoney,player2DayExp,player2Level,player2TotalExp,player2Weapon1Level,
                                         
                                         weapon1IsUpdate_2,player2Weapon2Level,weapon2IsUpdate_2,player2Weapon3Level,weapon3IsUpdate_2,player2Weapon4Level,weapon4IsUpdate_2,player2Weapon5Level,weapon5IsUpdate_2,player2Weapon6Level,weapon6IsUpdate_2,
                                         player2WeaponBulletCount,player2WeaponBulletMoney,player2WeaponUpdateCount, player2WeaponUpdateMoney , player3DayExp, player3Level, player3TotalExp, player3Weapon1Level,weapon1IsUpdate_3,
                                          player3Weapon2Level,weapon2IsUpdate_3,player3Weapon3Level,weapon3IsUpdate_3,player3Weapon4Level,weapon4IsUpdate_3,player3Weapon5Level,weapon5IsUpdate_3,player3Weapon6Level,weapon6IsUpdate_3,player3WeaponBulletCount,
                                          player3WeaponBulletMoney,player3WeaponUpdateCount,player3WeaponUpdateMoney,player4DayExp,player4Level,player4TotalExp,player4Weapon1Level,weapon1IsUpdate_4,player4Weapon2Level,weapon2IsUpdate_4,
                                          player4Weapon3Level,weapon3IsUpdate_4,player4Weapon4Level,weapon4IsUpdate_4,player4Weapon5Level,weapon5IsUpdate_4,player4Weapon6Level,weapon6IsUpdate_4,player4WeaponBulletCount,player4WeaponBulletMoney,
                                          player4WeaponUpdateCount,player4WeaponUpdateMoney,player5DayExp,player5Level,player5TotalExp,player5Weapon1Level,weapon1IsUpdate_5,player5Weapon2Level,weapon2IsUpdate_5,player5Weapon3Level,weapon3IsUpdate_5,
                                          player5Weapon4Level,weapon4IsUpdate_5,player5Weapon5Level,weapon5IsUpdate_5,player5Weapon6Level,weapon6IsUpdate_5,player5WeaponBulletCount,player5WeaponBulletMoney,player5WeaponUpdateCount,player5WeaponUpdateMoney,
                   totalMoney,totalTime,deviceid,gamename,whatday,createdate,date) 
                    VALUES('$dayGetMoney','$dayIap1BuyTimes','$dayIap2BuyTimes','$dayIap3BuyTimes','$dayIap4BuyTimes','$dayIap5BuyTimes','$dayIap6BuyTimes','$dayIapMoney','$dayPlayTime','$dayTotalTime','$dayUI1TapCount','$dayUI2TapCount','$dayUI3TapCount','$dayUI4TapCount',
                           '$dayUI5TapCount','$dayUI6TapCount','$dayUI7TapCount','$dayUI8TapCount','$dayUI9TapCount','$dayUsedMoney','$firstlogindata','$firstlogindata','$fromNotificationCount','$isjailbreak','$lastMission','$lastMissionState','$lastMissionType',
                           '$lastTapUI','$mission1End','$mission1Exit','$mission1Retry','$mission1Select','$mission2End','$mission2Exit','$mission2Retry','$mission2Select','$mission3End','$mission3Exit','$mission3Retry',
                           '$mission3Select','$mission4End','$mission4Exit','$mission4Retry','$mission4Select','$mission5End','$mission5Exit','$mission5Retry','$mission5Select','$mission6End','$mission6Exit','$mission6Retry',
                           '$mission6Select', '$mission7End','$mission7Exit','$mission7Retry','$mission7Select','$mission8End','$mission8Exit','$mission8Retry','$mission8Select','$nowMoney','$player1DayExp','$player1Level','$player1TotalExp',
                            '$player1Weapon1Level', '$weapon1IsUpdate','$player1Weapon2Level','$weapon2IsUpdate','$player1Weapon3Level','$weapon3IsUpdate','$player1Weapon4Level','$weapon4IsUpdate','$player1Weapon5Level','$weapon5IsUpdate',
                           '$player1Weapon6Level', '$weapon6IsUpdate', '$player1WeaponBulletCount','$player1WeaponBulletMoney','$player1WeaponUpdateCount','$player1WeaponUpdateMoney','$player2DayExp','$player2Level','$player2TotalExp','$player2Weapon1Level',
                            '$weapon1IsUpdate_2', '$player2Weapon2Level','$weapon2IsUpdate_2','$player2Weapon3Level','$weapon3IsUpdate_2','$player2Weapon4Level','$weapon4IsUpdate_2','$player2Weapon5Level','$weapon5IsUpdate_2','$player2Weapon6Level','$weapon6IsUpdate_2',
                              '$player2WeaponBulletCount','$player2WeaponBulletMoney','$player2WeaponUpdateCount','$player2WeaponUpdateMoney','$player3DayExp','$player3Level','$player3TotalExp','$player3Weapon1Level','$weapon1IsUpdate_3',
                              '$player3Weapon2Level', '$weapon2IsUpdate_3','$player3Weapon3Level','$weapon3IsUpdate_3','$player3Weapon4Level','$weapon4IsUpdate_3','$player3Weapon5Level','$weapon5IsUpdate_3','$player3Weapon6Level','$weapon6IsUpdate_3','$player3WeaponBulletCount',
                            '$player3WeaponBulletMoney', '$player3WeaponUpdateCount','$player3WeaponUpdateMoney','$player4DayExp','$player4Level','$player4TotalExp','$player4Weapon1Level','$weapon1IsUpdate_4','$player4Weapon2Level','$weapon2IsUpdate_4',
                             '$player4Weapon3Level', '$weapon3IsUpdate_4','$player4Weapon4Level','$weapon4IsUpdate_4','$player4Weapon5Level','$weapon5IsUpdate_4','$player4Weapon6Level','$weapon6IsUpdate_4','$player4WeaponBulletCount','$player4WeaponBulletMoney',
                               '$player4WeaponUpdateCount', '$player4WeaponUpdateMoney','$player5DayExp','$player5Level','$player5TotalExp','$player5Weapon1Level','$weapon1IsUpdate_5','$player5Weapon2Level','$weapon2IsUpdate_5','$player5Weapon3Level','$weapon3IsUpdate_5',
                              '$player5Weapon4Level',  '$weapon4IsUpdate_5','$player5Weapon5Level','$weapon5IsUpdate_5','$player5Weapon6Level','$weapon6IsUpdate_5','$player5WeaponBulletCount','$player5WeaponBulletMoney','$player5WeaponUpdateCount','$player5WeaponUpdateMoney',
                    '$totalMoney', '$totalTime','$deviceid','$gamename','$whatday','$createdate','$createdate')") or die(mysql_error());
    }
}
fclose($handle);
//fclose($fp);
print "Import successful!<br>";
//$results = mysql_query("select count(*) from logs where createdate like '2011-12-01%'");
//$count = mysql_fetch_row($results); {
// $showtime = date("Y-m-d");
//   echo "$showtime 统计:" . $count[0] . "<br>";
//}

/* function exportToCsv($csv_data, $filename = 'export.csv') {
  $csv_terminated = "\n";
  $csv_separator = ",";
  $csv_enclosed = '"';
  $csv_escaped = "\\";
  // Gets the data from the database
  $schema_insert = '';
  $out = '';
  //  $destination_folder = './file/';
  // Format the data
  foreach ($csv_data as $row) {
  $schema_insert = '';
  $fields_cnt = count($row);
  //printr($row);
  $tmp_str = '';
  foreach ($row as $v) {
  $tmp_str .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $v) . $csv_enclosed . $csv_separator;
  } // end for

  $tmp_str = substr($tmp_str, 0, -1);
  $schema_insert .= $tmp_str;

  $out .= $schema_insert;
  $out .= $csv_terminated;
  } // end while
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Content-Length: " . strlen($out));
  header("Content-type: text/x-csv");
  // header("Content-Disposition:filename=$filename");
  header('Content-Disposition:inline;filename="'.$filename.'"');   //auto
  echo $out;
  }
  $dateTime = date("Y-m-d",strtotime("-2 day"));

  $results = mysql_query("select count(id),sum(days),sum(gametime),count(DISTINCT deviceid),count(DISTINCT deviceid),count(DISTINCT deviceid) from logs where createdate like '$dateTime%'");
  $count = mysql_fetch_row($results); {
  // $showtime = date("Y-m-d");
  //echo "$showtime 统计:" . $count[0] . "<br>";
  }
  // var_dump($count);
  $csv_data = array(array('id', 'days','游戏时长','登陆人次','活跃人数','deviceid'));
  array_push($csv_data, array($count[0],$count[1],$count[2],$count[3],$count[4],$count[5],$count[6]));
  exportToCsv($csv_data, "$dateTime.csv");
 */
?>
